package com.campus.server.dao;

import com.campus.common.util.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class PasswordChangeDao {
    public boolean isChange(String username,String password){
        try (Connection conn = DBUtil.getConnection();
             PreparedStatement ps = conn.prepareStatement(
                     "UPDATE user1 SET password = ? WHERE username = ?")) {
            conn.setAutoCommit(true);  // 确保立即提交
            ps.setString(1, password);
            ps.setString(2, username);
            int rows = ps.executeUpdate();
            System.out.println("更新行数: " + rows); // 调试用
            return rows > 0;
        } catch (Exception e) { e.printStackTrace(); }
        return false;
    }
}
